{{ template "header.html" }}

<div class="item">
    <div>时间戳 ===> 时间</div>
    <label>
        <input type="text" name="unix" placeholder="时间戳" value="{{ .unix }}">
        <button onclick="timeStampToTime()">转化</button>
        <input type="text" id="time" placeholder="时间" readonly>
    </label>
</div>

<div class="item">
    <div>时间 ===> 时间戳</div>
    <label>
        <input type="text" name="time" placeholder="时间" value="{{ .time }}">
        <button onclick="timeToTimeStamp()">转化</button>
        <input type="text" id="unix" placeholder="时间戳" readonly>
    </label>
</div>

<script>
    function timeStampToTime() {
        var unix = $("input[name='unix']").val()
        $.post("/time-stamp-to-time", {"unix" : unix}, function (res) {
            var time = res.time
            $("#time").val(time)
        }, "json")
    }
    function timeToTimeStamp() {
        var time = $("input[name='time']").val()
        $.post("/time-to-time-stamp", {"time" : time}, function (res) {
            var unix = res.unix
            $("#unix").val(unix)
        }, "json")
    }
</script>

{{ template "footer.html" }}